<#--  
aoColNum 列的数量 
collist 设置每个列详细参数，优先选择

eg:
<@tablePage aoColNum=10 collist='[{ "bSortable": false },{ "bSortable": false },{ "bSortable": false },{ "bSortable": false },{ "bSortable": false },null,{ "bSortable": false },null,{ "bSortable": false },{ "bSortable": false }]'/>
--> 
<#macro tablepage colnum=10 collist="">  
<script type="text/javascript"> 
var Page = function () { 

    return { 
        //main function to initiate the module
        init: function () {
            
            if (!jQuery().dataTable) {
                return;
            }

            // begin table
            $('#sample_1').dataTable({
                "aoColumns":[
                  <#if (collist?size > 0)>
	                  <#list collist as x>
	                     <#if x_index=0>
	                     { "bSortable": false },
	                     <#elseif x_has_next!="true">
	                     { "bSortable":<#if x=1> true <#else> false </#if>}
						 <#else>
						 { "bSortable":<#if x=1> true <#else> false </#if>},
						 </#if>
						 </#list>
                  <#else> 
                       <#list 1..colnum as x> 
	                     <#if x_has_next!="true">
						   { "bSortable": false }
						<#else>
					   { "bSortable": false },
						</#if>
                  </#list>
                  </#if>
                ],
                "aLengthMenu": [
                    [5, 12, 20, -1],
                    [5, 12, 20, "All"] // change per page values here
                ],
                // set the initial value
                //${colnum},
                "iDisplayLength": 12,
                "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
                "sPaginationType": "bootstrap",
                "oLanguage": {
                    "sLengthMenu": "_MENU_ records per page",
                    "oPaginate": {
                        "sPrevious": "Prev",
                        "sNext": "Next"
                    }
                },
                "aoColumnDefs": [{
                        'bSortable': false,
                        'aTargets': [0]
                    }
                ]
            });

            jQuery('#sample_1 .group-checkable').change(function () {
                var set = jQuery(this).attr("data-set");
                var checked = jQuery(this).is(":checked");
                jQuery(set).each(function () {
                    if (checked) {
                        $(this).attr("checked", true);
                    } else {
                        $(this).attr("checked", false);
                    }
                });
                jQuery.uniform.update(set);
            });

            jQuery('#sample_1_wrapper .dataTables_filter input').addClass("m-wrap medium"); // modify table search input
            jQuery('#sample_1_wrapper .dataTables_length select').addClass("m-wrap small"); // modify table per page dropdown
            //jQuery('#sample_1_wrapper .dataTables_length select').select2(); // initialzie select2 dropdown  

        }

    };

}(); 
</script> 
</#macro>
